<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
    <style>
      #app {
        font-family: Avenir, Helvetica, Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-align: center;
        color: #2c3e50;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <h1>v-show条件渲染</h1>
      <button @click="type=1">新闻</button>
      <button @click="type=2">音乐</button>
      <button @click="type=3">运动</button>

      <!-- <h2 v-show="type===1">我是新闻</h2>
    <h2 v-show="type===2">我是音乐</h2>
    <h2 v-show="type===3">我是运动</h2> -->

      <!-- <template v-show="type===1">
        <h2>我是新闻</h2>
      </template>
      <template v-show="type===2">
        <h2>我是音乐</h2>
      </template>
      <template v-show="type===3">
        <h2>我是运动</h2>
      </template> -->

      <div v-show="type===1">
        <h2>我是新闻</h2>
        <input type="text">
      </div>
      <div v-show="type===2">
        <h2>我是音乐</h2>
        <input type="text">
      </div>
      <div v-show="type===3">
        <h2>我是运动</h2>
        <input type="text">
      </div>
    </div>
    <script>
      Vue.config.productionTip = false;
      //实例化Vue
      const vm = new Vue({
        el: "#app",
        data() {
          return {
            type: 1,
          };
        },
      });
    </script>
  </body>
</html>
